<template>
    <div class="">
        <div class="accountPos">
            <span>账户流水</span>
            <ul>
                <li v-for="(tab,index) in tabs" :class="{ on:selected == index }" v-text="tab.text" @click="changeTab(index)"></li>
            </ul>
        </div>
        <div class="accountFlowingTit">
            <ul>
                <li class="first">流水号</li>
                <li>业务类型</li>
                <li>业务描述</li>
                <li>交易金额（元）</li>
                <li>创建时间</li>
            </ul>
        </div>
        <div class="accountFlowing">
            <ul>
                <li v-for="(flowing, index) in flowings">
                    <span v-text="flowing.id"></span>
                    <span v-text="flowing.transName"></span>
                    <span v-html="flowing.amount.toFixed(2)"></span>
                    <span v-text="flowing.subTransCodeName"></span>
                    <span v-text="flowing.addTime"></span>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
    import Api from '../api/api'
    const api = new Api();
    export default {
        data(){
            return {
                flowings: '',
                tabs: [
                    { text: '全部'},
                    { text: '充值'},
                    { text: '还款'},
                    { text: '提现'},
                    { text: '放款'}
                ],
                selected: 0
            }
        },
        created(){
            let param = {
                token: sessionStorage.getItem('token'),
                keyWord: 0
            };
            api.getFlowing(param).then(res=>{
                if(res.data.success){
                    this.flowings = res.data.data.financieraccountflowlist
                }else{
                    console.log(`左边栏目，个人信息接口请求失败！${res.data.cause}`)
                }
            }).catch(err=>{
                console.log(err)
            })
        },
        methods: {
            changeTab(index){
                this.selected = index
                let param = {
                    token: sessionStorage.getItem('token'),
                    keyWord: index
                };
                api.getFlowing(param).then(res=>{
                    if(res.data.success){
                        this.flowings = res.data.data.financieraccountflowlist
                    }else{
                        console.log(`左边栏目，个人信息接口请求失败！${res.data.cause}`)
                    }
                }).catch(err=>{
                    console.log(err)
                })
            }
        }
    }
</script>